﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ayatta.Contract;
using Enyim.Caching;

namespace Web.Core.Controllers
{
    public class CommonController : CoreController
    {
        public CommonController(Lazy<IInfrastructureService> infrastructure, Lazy<IPassportService> passport, Lazy<IAccountService> account, Lazy<IStoreService> store, Lazy<ITradeService> trade, Lazy<IPlayService> play, Lazy<IMiscService> misc, Lazy<IExtraService> extra, IMemcachedClient memcachedClient)
            : base(infrastructure, passport, account, store, trade, play, misc, extra, memcachedClient)
        {
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Area(string param)
        {
            var data = AreaList().Where(o => o.ParentId == param);
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        #region
        /// <summary>
        /// 商品分类
        /// </summary>
        /// <param name="param">ParentId</param>
        /// <returns></returns>
        public ActionResult ProductCategory(int param = 0)
        {
            var data = ProductCategoryList(param);
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 商品属性
        /// </summary>
        /// <param name="param">CategoryId</param>
        /// <returns></returns>
        public ActionResult ProductCategoryProp(int param = 0)
        {
            var props = ProductCategoryPropList(param);
            var propValues = ProductCategoryPropValueList(param);
            var data = new { Props = props, PropValues = propValues };
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        #endregion
    }
}
